﻿package mortal.game.view.treasureMap
{
    import Message.Public.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.activeTime.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class TreasureMapAvctivityWin extends Window
    {
        private var _bg:GImageBitmap;
        private var _btnDigging:GLoadingButton;
        private var _time:GTextFiled;
        private var _mapNum:GTextFiled;
        private static var _instance:TreasureMapAvctivityWin;

        public function TreasureMapAvctivityWin(param1:ILayer = null)
        {
            super(param1);
            if (_instance)
            {
                throw new Error("单例");
            }
            this.setSize(833, 554);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.titleHeight = 180;
            this._bg = UIFactory.gImageBitmap(ImagesConst.TreasureActivityBg, 0, -17, this);
            this._btnDigging = UIFactory.gLoadingButton(ResFileConst.tresureMapActivityBtn, 364, 476, 110, 44, this);
            this._btnDigging.configEventListener(MouseEvent.CLICK, this.clickHandler);
            this._btnDigging.toolTipData = Language.getString(35576);
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 20;
            this._time = UIFactory.gTextField("", 145, 73, 150, 35, this, _loc_1);
            this._mapNum = UIFactory.gTextField("", 570, 472, 150, 22, this, GlobalStyle.textFormatItemGreen);
            this._mapNum.toolTipData = Language.getString(35576);
            this.updateMapNum();
            this.updateTime();
            this.configEventListener(MouseEvent.MOUSE_DOWN, onMouseDownHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg.dispose(param1);
            this._bg = null;
            this._btnDigging.dispose(param1);
            this._btnDigging = null;
            this._time.dispose(param1);
            this._time = null;
            this._mapNum.dispose(param1);
            this._mapNum = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override protected function updateBtnSize() : void
        {
            if (_closeBtn)
            {
                _closeBtn.x = this.width - _closeBtn.width - 22;
                _closeBtn.y = 2;
                _contentTopOf3DSprite.addChild(_closeBtn);
            }
            return;
        }// end function

        private function updateTime() : void
        {
            this._time.text = ActiveTimeUtil.getTodaySClientActiveTimeTxt(EActiveType._EActiveTypeTreasureMap);
            return;
        }// end function

        private function updateMapNum() : void
        {
            this._mapNum.text = Language.getStringByParam(35577, Cache.instance.pack.backPackCache.getItemCountByCategoryAndType(EGroup._EGroupProp, EProp._EPropProp, EPropType._EPropTypeTreasureMap));
            return;
        }// end function

        private function clickHandler(event:MouseEvent) : void
        {
            var _loc_2:* = Cache.instance.pack.backPackCache.getItemsByGroupCategoryAndType(EGroup._EGroupProp, EProp._EPropProp, EPropType._EPropTypeTreasureMap);
            if (_loc_2 && _loc_2.length)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.BackPack_Use, _loc_2[0]));
                this.hide();
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(35578), MsgRollTipsType.msgRollTips3);
            }
            return;
        }// end function

        public static function get instance() : TreasureMapAvctivityWin
        {
            if (!_instance)
            {
                _instance = new TreasureMapAvctivityWin;
            }
            return _instance;
        }// end function

        public static function get isViewShow() : Boolean
        {
            return _instance && !_instance.isHide;
        }// end function

    }
}
